#include <iostream>
#include <vector>
using namespace std;
/*
    对输入的n个测试矩阵
    1. 按照顺序全部读取成序列，存入vector
    2. 对vector中每个数字num，计算f(num),并不断累加求和
    3. 判断是否为偶排列，是：返回yes，否：返回no
*/
vector<int> list;
int f(int num)
{
    int total = 0;
    for (size_t i = 0; i < list.size(); i++)
    {
        if (list[i] > num)
        {
            total += 1;
        }
    }
    return total;
}
int main()
{
    int n, temp;
    cin >> n;
    int res;
    while (n--)
    {
        for (size_t i = 0; i < 9; i++)
        {
            cin >> temp;
            if (temp != 0)
            {
                list.push_back(temp);
                res += f(temp);
            }
        }
        if (res % 2 == 0)
        {
            cout << res;
            cout << "yes";
        }
        else
            cout << "no";
    }

    return 0;
}